﻿using LimaLims.Application.Service.Base.Dto;
using LimaLims.Core;
using LimaLims.Core.Enum;
using Qiniu.Util;
using StackExchange.Redis;
using System;
using System.Buffers.Text;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LimaLims.Application.Service.User.Dto
{
    public class UserInput : PageInputBase
    {
        /// <summary>
        /// 班组ID
        /// </summary>
        public long? TeamId { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        public string Account { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 手机
        /// </summary>
        public string Phone { get; set; }
    }

    /// <summary>
    /// 更新用户授权数据角色和数据范围
    /// </summary>
    public class UpdateUserRoleDataInput : IXnInputBase
    {
        public long Id { get; set; }
        public List<long> GrantMenuIdList { get; set; }
        public List<long> GrantRoleIdList { get; set; }
    }

    public class AddUserInput : BaseDto
    {
        /// <summary>
        /// 班组ID
        /// </summary>
        public long? TeamId { get; set; }
        /// <summary>
        /// 账号
        /// </summary>
        [Required(ErrorMessage = "账号名称不能为空")]
        public string Account { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [Required(ErrorMessage = "密码不能为空")]
        public string Password { get; set; }

        /// <summary>
        /// 确认密码
        /// </summary>
        [Required(ErrorMessage = "确认密码不能为空"), Compare(nameof(Password), ErrorMessage = "两次密码不一致")]
        public string Confirm { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar { get; set; }

        /// <summary>
        /// 生日
        /// </summary>
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 性别-男_1、女_2
        /// </summary>
        public int Sex { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 手机
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Tel { get; set; }
        public int AdminType { get; set; }

        /// <summary>
        /// 角色集合
        /// </summary>
        public List<long> RoleIdList { get; set; }
    }
    /// <summary>
    /// 修改用户基本信息
    /// </summary>
    public class UpdateUsreBase
    {
        public long? Id { get; set; }
        /// <summary>
        /// 账号
        /// </summary>
        public string Account { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar { get; set; }

        /// <summary>
        /// 生日
        /// </summary>
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 性别-男_1、女_2
        /// </summary>
        public Gender Sex { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 手机
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Tel { get; set; }
    }

    public class UpdateUserInput : BaseDto
    {
        /// <summary>
        /// 班组ID
        /// </summary>
        public long? TeamId { get; set; }
        /// <summary>
        /// 账号
        /// </summary>
        [Required(ErrorMessage = "账号名称不能为空")]
        public string Account { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar { get; set; }

        /// <summary>
        /// 生日
        /// </summary>
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 性别-男_1、女_2
        /// </summary>
        public int Sex { get; set; }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 手机
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Tel { get; set; }

        public int AdminType { get; set; }

        /// <summary>
        /// 角色集合
        /// </summary>
        public List<long> RoleIdList { get; set; }
    }

    /// <summary>
    /// 更新用户基本信息
    /// </summary>
    public class UpdateUserBaseInfoInput : BaseDto
    {
        [Required(ErrorMessage = "手机号不能为空")]
        public string Phone { get; set; }

        [Required(ErrorMessage = "电子邮箱不能为空")]
        public string Email { get; set; }

        [Required(ErrorMessage = "性别不能为空")]
        public int Sex { get; set; }

        [Required(ErrorMessage = "生日不能为空")]
        public DateTime? Birthday { get; set; }

        public string Tel { get; set; }
    }

    /// <summary>
    /// 修改密码
    /// </summary>
    public class ChangePasswordUserInput : BaseDto
    {
        /// <summary>
        /// 密码
        /// </summary>
        [Required(ErrorMessage = "旧密码不能为空")]
        public string Password { get; set; }

        /// <summary>
        /// 新密码
        /// </summary>
        [Required(ErrorMessage = "新密码不能为空")]
        [StringLength(32, MinimumLength = 6, ErrorMessage = "密码需要大于6个字符")]
        public string NewPassword { get; set; }
    }

    public class UploadAvatarInput : BaseDto
    {
        /// <summary>
        /// 头像文件路径标识
        /// </summary>
        [Required(ErrorMessage = "头像文件路径标识不能为空")]
        public string Avatar { get; set; }
    }

    public class UserOutput
    {
        /// <summary>
        /// Id
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        public string Account { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar { get; set; }

        /// <summary>
        /// 生日
        /// </summary>
        public DateTimeOffset? Birthday { get; set; }

        /// <summary>
        /// 性别-男_1、女_2
        /// </summary>
        public Gender Sex { get; set; }

        /// <summary>
        /// 性别文本
        /// </summary>
        public string SexText => Sex.ToString();

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 手机
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 班组ID
        /// </summary>
        public long? TeamId { get; set; }

        /// <summary>
        /// 班组名称
        /// </summary>
        public string TeamName { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Tel { get; set; }

        /// <summary>
        /// 账号类型
        /// </summary>
        public AdminType AdminType { get; set; }

        /// <summary>
        /// 账号类型文本
        /// </summary>
        public string AdminTypeText => AdminType.ToString();

        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime? UpdatedTime { get; set; }
    }

    public class UserNameOutput
    {
        /// <summary>
        /// Id
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }

       
    }
}
